//
//  CZUserStatus.swift
//  weibo27
//
//  Created by mac on 16/4/18.
//  Copyright © 2016年 it.cast. All rights reserved.
//

import UIKit

class CZUserStatus: NSObject {
    
    /// 微博来源
    var source: String?
    /// 微博ID  基本的数据类型要进行初始化.每一个cell的id
    var id: Int = 0
    /// 微博信息内容
    var text: String?
    /// 微博创建时间
    var created_at: String?
    /// 图片数组 不是属于CZUser的而是属于整个CZUserStatus的属性
    var pic_urls:[[String: String]]?
    /// 用户模型
    var user: CZUser?
    /// 被转发的原微博信息字段，当该微博为转发微博时返回
    var retweeted_status:CZUserStatus?
    
    init(dict: [String: AnyObject]) {
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        //在转模型的时候如果遇到了双模型就要再转一次
        if key == "user"{
            
            if  let dict = value as? [String: AnyObject]{
                user = CZUser(dict: dict)
            }
            return
        }
        
        if key == "retweeted_status"{
            
            if  let dict = value as? [String: AnyObject]{
                retweeted_status = CZUserStatus(dict: dict)
            }
            return
        }
        
        super.setValue(value, forKey: key)
    }
    //未被设置的键值
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
        
    }
    
    override var description: String{
        
        let keys = ["source","id","text","created_at","user","pic_urls","retweeted_status"]
        
        return dictionaryWithValuesForKeys(keys).description
    }
    
}
